package cn.smbms.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.smbms.pojo.Hot;
import cn.smbms.pojo.Product;
import cn.smbms.service.hot.HotService;
import cn.smbms.service.product.ProductService;

@Controller
public class InitalizeController {
	@Resource
	private ProductService productService;
	@Resource
	private HotService hotService;

	// 初始页面
	@RequestMapping(value = "/refindex.html")
	public String refindex(Model model) {
		List<Product> pList = productService.getImgs();
		// 轮播图
		model.addAttribute("pList", pList);
		// 实现按照typeid查询product
		/* 母婴 */
		List<Product> myList = productService.getImgsByTypeId(1);
		/* 女装 */
		List<Product> nzList = productService.getImgsByTypeId(2);
		/* 男装 */
		List<Product> manList = productService.getImgsByTypeId(3);
		/* 内衣服饰 */
		List<Product> nyList = productService.getImgsByTypeId(4);
		/* 化妆品 */
		List<Product> hzList = productService.getImgsByTypeId(5);
		/* 居家百货 */
		List<Product> bhList = productService.getImgsByTypeId(6);
		/* 时尚智能 */
		List<Product> ssList = productService.getImgsByTypeId(7);
		/* 营养保健 */
		List<Product> bjList = productService.getImgsByTypeId(8);
		/* 女鞋箱包 */
		List<Product> nxList = productService.getImgsByTypeId(9);
		/* 热门搜索 */

		model.addAttribute("myList", myList);
		model.addAttribute("nzList", nzList);
		model.addAttribute("manList", manList);
		model.addAttribute("nyList", nyList);
		model.addAttribute("hzList", hzList);
		model.addAttribute("bhList", bhList);
		model.addAttribute("ssList", ssList);
		model.addAttribute("bjList", bjList);
		model.addAttribute("nxList", nxList);

		return "refindex";
	}

	// 初始页面
	@RequestMapping(value = "/index.html")
	public String index(Model model) {
		List<Product> pList = productService.getImgs();
		// 轮播图
		model.addAttribute("pList", pList);
		// 实现按照typeid查询product
		/* 母婴 */
		List<Product> myList = productService.getImgsByTypeId(1);

		/* 热门搜索 */
		List<Hot> hotList = hotService.getList();
		model.addAttribute("myList", myList);

		model.addAttribute("hotList", hotList);
		return "index";
	}
}
